/*
 * CreepFastForward.java
 *
 * Created on February 24, 2008, 1:11 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package hextd.creep;

import hextd.util.Cache;
import hextd.core.Context;
import hextd.util.Geometry;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Shape;
import java.awt.Stroke;

/**
 *
 * @author hylke
 */
public class CreepFastForward extends CreepBaseDirectional {

	public static String type = "ff";
	//
	private Color bodyColor = new Color(100, 150, 200);
	private static String infoText =
			"<h1>FastForward</h1>" +
			"<p>" +
			"It's going forward fast. Catch it if you can!<br>" +
			"</p>";

	@Override
	protected void doInit(Context context, int owner, int path, float delay, long health, int price, int score, Creep.Size s) {
		super.doInit(context, owner, path, delay, health * 8 / 10, price, score, s);
		this.speed = 100;        // * 1/1000 segments per tick
		this.speedMax = 100;     // * 1/1000 segments per tick
		this.speedMaxBase = 100; // * 1/1000 segments per tick
		this.power = 100;        // power > speedMax => speed = speedMax
		this.powerBase = 100;    // power > speedMax => speed = speedMax
	}

	@Override
	public String getType() {
		return type;
	}

	@Override
	public String getInfoString() {
		return CreepFastForward.infoText +
				"<p>" + super.getInfoString() + "</p>";
	}

	/** Creates a new instance of CreepFastForward */
	public CreepFastForward() {
		super("Fast Forward");
	}

	@Override
	String getSvgName() {
		return null;
	}

	@Override
	Shape[] generateShapes() {
		Shape[] shapes;
		Cache cache = cn.getCache();
		if (cache.hasShapeArr("ESFFShapes" + this.size.letter)) {
			shapes = cache.getShapeArr("ESFFShapes" + this.size.letter);
		} else {
			int frames = 16;
			shapes = new Shape[frames];

			double dr = 2.0 * Math.PI / frames;
			double r = 0;
			for (int i = 0; i < shapes.length; i++) {

				float scale = paintScale * this.size.scaleMod;
				float[][] points = {
					{scale * (-5.5f + 5 * (float) Math.sin(-r)) / 24, +scale * (3.5f + 1.75f * (float) Math.cos(-r)) / 24},
					{scale * (1.5f + 5 * (float) Math.sin(-r)) / 24, +scale * (3.5f + 1.75f * (float) Math.cos(-r)) / 24},
					{scale * (0.0f) / 24, 0},
					{scale * (5.5f) / 24, 0},
					{scale * (0.0f) / 24, 0},
					{scale * (1.5f + 5 * (float) Math.sin(-r)) / 24, -scale * (3.5f + 1.75f * (float) Math.cos(-r)) / 24},
					{scale * (-5.5f + 5 * (float) Math.sin(-r)) / 24, -scale * (3.5f + 1.75f * (float) Math.cos(-r)) / 24}
				};
				shapes[i] = Geometry.coordsToGeneralPath(points, false);
				r += dr;
			}
			cache.putShapeArr("ESFFShapes" + this.size.letter, shapes);
		}
		return shapes;
	}

	@Override
	Stroke generateStroke() {
		return new BasicStroke(2.5f * strokeScale, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
	}

	@Override
	Color generateColor() {
		return this.bodyColor;
	}
}
